<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('我的待办')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                        <li class="select-time">
                            <label>创建时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                        </li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('business:carPackageAudit:edit')}]];
    var removeFlag = [[${@permission.hasPermi('business:carPackageAudit:remove')}]];
    var statusDatas = [[${@dict.getType('cpa_status')}]];
    var prefix = ctx + "business/carPackageAudit";

    $(function () {
        var options = {
            url: prefix + "/todoList",
            modalName: "我的待办",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '审核服务项ID',
                    visible: false
                },
                {
                    field: 'serviceItem.name',
                    title: '套餐名称'
                },
                {
                    field: 'serviceItem.discountPrice',
                    title: '套餐价格'
                },
                {
                    field: 'serviceItem.info',
                    title: '套餐备注',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value, 5);
                    }
                },
                {
                    field: 'createByName',
                    title: '创建人'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'taskName',
                    title: '当前任务名称'
                },
                {
                    field: 'status',
                    title: '审核状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'auditors',
                    title: '当前节点审核人'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if(row.status==0){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="showVerifyDialog(\'' + row.taskId + '\', \'' + row.taskName + '\')"><i class="fa fa-edit"></i> 审批</a> ');
                        }else{
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="openServiceItemsEditPage(\'' + row.id + '\')"><i class="fa fa-edit"></i> 修改表单</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="reApply(\'' + row.taskId + '\', \'' + row.id + '\')"><i class="fa fa-edit"></i> 重新申请</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="showHistoryDialog(\'' + row.instanceId + '\')"><i class="fa fa-list"></i>历史审批</a> ');
                        actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="showProcessImgDialog(\'' + row.instanceId + '\')"><i class="fa fa-image"></i>进度查看</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function showProcessImgDialog(instanceId) {
        var url = prefix + '/processImg?instanceId='+instanceId;
        $.modal.open("查看流程图",url);
    }

    function showVerifyDialog(taskId,taskName) {
        var url = prefix + '/showVerifyDialog/'+taskId;
        $.modal.open(taskName,url);
    }

    function openServiceItemsEditPage(carPackageAuditId) {
        var url = prefix + '/openServiceItemsEditPage/'+carPackageAuditId;
        $.modal.open("修改表单",url);
    }

    function reApply(taskId,carPackageAuditId) {
        $.modal.confirm("确认要重新发起申请吗?", function() {
            var url = prefix + '/reApply';
            var data = {"taskId":taskId,"carPackageAuditId":carPackageAuditId};
            $.operate.post(url,data);
        });
    }

    function showHistoryDialog(instanceId) {
        var url = prefix + '/historyList/' + instanceId;
        $.modal.open("查看审批历史",url);
    }
</script>
</body>
</html>